/*
 * dv.c
 * Jonathan Marokhovsky
 * WPI 2011
 * Possible arguments:
 *	-h
 *
 */
#include <stdio.h>
#include <stdlib.h> // for getenv()
#include <sys/stat.h> // for stat()
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>

#define MAX_SIZE 257

void usage(void);

char *trash;

int main(int argc, char *argv[])
{
	char theTrash[MAX_SIZE];
	int errflag;
	
	trash = theTrash;
	trash = getenv(TRASH);
	if (!trash) // if the trash variable hasn't been defined, ABORT
	{
		fprintf(stderr, "ERROR: no trash environment variable set.\n");
		fprintf(stderr, "ERROR: set it with 'export TRASH=[trash directory]' in the shell.\n");
		usage();
	}
	
	if (argc < 2)
	{
		errflag++;
	}
	
	// parse for the h flag
	while ((c = getopt(argc, argv, "h")) != EOF)
	{
		//indexToAdd = optind - 1;
		switch (c)
		{
			case '?':
			case 'h':
			default:
				errflag++;
		}
	}
	
	if (errflag) usage();
	else
	{
		// dive for the file
	}
	
	return 0;
}

/* This prints the usage message and quits */
void usage(void)
{
	fprintf(stderr, "Usage: dv [OPTION]\n");
	fprintf(stderr, "OR: dv FILE...\n");
	fprintf(stderr, "Dive for FILE in the trash. This restores the file to the cwd.\n");
	fprintf(stderr, "\t-h\t\tdisplay this help message\n");
	exit(1);
}

/* This checks to see whether the given file is there */

/* This checks the permissions on the given file */

/* This returns the requested file */

/* This gets the current working directory */
